/***************************************************************************

-------------------
    begin                : 
    copyright            : kuzkok
    email                : kuzkok at gmail.com

***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*   
*   Данная программа является свободным программным обеспечением;         *
*   Вы можете распространять ее и/или модифицировать в соответствии с     *
*   GNU General Public License опубликованной Фондом свободного           *
*   программного обеспечения; используемая версия лицензии - 2 или        *
*   (по вашему выбору) любая более поздняя                                *
***************************************************************************/

#include "centerlinepoint.h"

CenterlinePoint::CenterlinePoint(QString theTableName) :
    ObjectArchive(theTableName)
{
}

CenterlinePoint::CenterlinePoint(QUuid theEventID, QString theTableName) :
        ObjectArchive(theEventID, theTableName)
{
    if(mObjectState)
    {
        mCLControl = mSelectQuery->value(mSelectQuery->record().indexOf("clcontrol")).toString();
        mCLStationEditResponse = mSelectQuery->value(mSelectQuery->record().indexOf("clstationeditresponse")).toString();
        mCLXYEditResponse = mSelectQuery->value(mSelectQuery->record().indexOf("clxyeditresponse")).toString();
        mCLZEditResponse = mSelectQuery->value(mSelectQuery->record().indexOf("clzeditresponse")).toString();
        mOperationalStatus = mSelectQuery->value(mSelectQuery->record().indexOf("operationalstatus")).toString();
        mGroupEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("groupeventid")).toString());
        mStationSeriesEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("stationserieseventid")).toString());
        mSymbolRotation = mSelectQuery->value(mSelectQuery->record().indexOf("symbolrotation")).toDouble();
    }
}

void CenterlinePoint::buildInsertStatement()
{
    ObjectArchive::buildInsertStatement();
    mInsertStatementFields += ", clcontrol"
                             ", clstationeditresponse"
                             ", clxyeditresponse"
                             ", clzeditresponse"
                             ", operationalstatus"
                             ", groupeventid"
                             ", stationserieseventid"
                             ", symbolrotation";
    mInsertStatementValues += ", :clcontrol"
                             ", :clstationeditresponse"
                             ", :clxyeditresponse"
                             ", :clzeditresponse"
                             ", :operationalstatus"
                             ", :groupeventid"
                             ", :stationserieseventid"
                             ", :symbolrotation";
}

void CenterlinePoint::buildUpdateStatement()
{
    ObjectArchive::buildUpdateStatement();
    mUpdateStatement += ",clcontrol = :clcontrol"
                       ",clstationeditresponse = :clstationeditresponse"
                       ",clxyeditresponse = :clxyeditresponse"
                       ",clzeditresponse = :clzeditresponse"
                       ",operationalstatus = :operationalstatus"
                       ",groupeventid = :groupeventid"
                       ",stationserieseventid = :stationserieseventid"
                       ",symbolrotation = :symbolrotation";
}

void CenterlinePoint::bindQueryValues(QSqlQuery &query)
{
    ObjectArchive::bindQueryValues(query);
    query.bindValue(":clcontrol", mCLControl);
    query.bindValue(":clstationedtiresponse", mCLStationEditResponse);
    query.bindValue(":clxyeditresponse", mCLXYEditResponse);
    query.bindValue(":clzeditresponse", mCLZEditResponse);
    query.bindValue(":operationalstatus", mOperationalStatus);
    query.bindValue(":groupeventid", UuidToVariant(mGroupEventID));
    query.bindValue(":stationserieseventid", UuidToVariant(mStationSeriesEventID));
    query.bindValue(":symbolrotation", mSymbolRotation);

}
